cc.Class({
    extends: cc.Component,

    properties: {
    },

    onLoad() {
        let nodeDict = {};

        var linkWidget = function (self, nodeDict) {
            var children = self.children;
            for (var i = 0; i < children.length; i++) {
                var widgetName = children[i].name;
                if (widgetName && widgetName.indexOf("btn") >= 0) {
                    var nodeName = widgetName;
                    if (nodeDict[nodeName]) {
                        cc.error("控件名字重复!" + children[i].name);
                    }
                    nodeDict[nodeName] = children[i];
                }
                if (children[i].childrenCount > 0) {
                    linkWidget(children[i], nodeDict);

                }
            }
        }.bind(this);
        linkWidget(this.node, nodeDict);

        // 给button注册事件
        for (let key in nodeDict) {
            var widgetName = nodeDict[key].name;
            if (widgetName && widgetName.indexOf("btn") >= 0) {
                nodeDict[key].on('click', this.buttonListener, this);
            }
        }
    },

    buttonListener(event) {
    },
});